package asteroids.model.programs.expressions.ComposedExpressions.UnaryExpressions;

import asteroids.model.programs.expressions.BasicExpression;
import asteroids.model.programs.expressions.Expression;
import asteroids.model.programs.expressions.BasicExpressions.BooleanLiteral;
import asteroids.model.programs.expressions.ComposedExpressions.UnaryExpression;
import asteroids.model.programs.types.Type;

public class Not extends UnaryExpression {

	/**
	 * Initialize the Not object
	 * 
	 * @param exp
	 * 			The operand of this expression
	 * @effect ...
	 * 			|super(exp, line, column)
	 */
	public Not(Expression exp, int line, int column){
		super(exp, line, column);
	}
	
	/**
	 * Returns the symbol for this Expression, namely !
	 * 
	 * @return ...
	 * 			| return "!"
	 */
	@Override
	public String getOperatorSymbol() {
		return "!";
	}

	/**
	 * Returns BasicExpression of type BooleanLiteral with the value of the sine function
	 * @return ...
	 * 			|result.equals(new BooleanLiteral(!(getOperand().getResult().getValue())))
	 */
	@Override
	public BasicExpression getResult() {
		boolean value = ((BooleanLiteral)getOperand().getResult()).getValue();
		BasicExpression result = new BooleanLiteral(!value, getLine(), getColumn());
		return result;
	}
	
	@Override
	public Type getType(){
		return Type.BOOLEAN;
	}
	
	@Override
	public Type[] getOperandType(){
		return new Type[]{Type.BOOLEAN};
	}
}
